export const rules = {
  Name: {
    required: true,
    message: '请输入方案名称',
    trigger: 'change',
  },
  UpgradeMode: {
    message: '请选择文件方式',
    type: 'number',
    trigger: 'change',
  },
  Ver: {
    required: true,
    message: '请输入版本号',
    trigger: 'change',
  },
  Path: {
    required: true,
    message: '请输入文件URL',
    trigger: 'change',
  },
}

export enum UpgradeMode {
  HTTP = 1,
  FTP = 0,
}

export interface UpdateFileForm {
  StateRemark: string
  Name: string
  GUID: string
  UpgradeMode: UpgradeMode
  Path: string
  Password: string
  UserName: string
  Ver: string
}

export function useInitForm(): { formData: Ref<UpdateFileForm>, initForm: () => void } {
  const getData = () => ({
    StateRemark: '',
    Name: '',
    GUID: '',
    UpgradeMode: UpgradeMode.FTP,
    Path: '',
    Password: '',
    Ver: '',
    UserName: '',
  })
  const formData = ref<UpdateFileForm>(getData())

  const initForm = () => {
    formData.value = getData()
  }

  return { formData, initForm }
}
